/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package webServices;

import businessLogic.DataMgr;
import businessLogic.LoanMgr;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.xml.bind.annotation.XmlSeeAlso;
import persistence.Client;
import persistence.Exemplar;
import persistence.Loan;
import persistence.Medium;
import persistence.MusikCd;
import persistence.SimpleBook;
import persistence.SpecialBook;
import persistence.XxxMovie;

/**
 *
 * @author breinesg
 */
@WebService(serviceName = "PublicService")
@Stateless()
@LocalBean
/**
 * 
 */
@XmlSeeAlso({SimpleBook.class, MusikCd.class, SpecialBook.class, XxxMovie.class})

public class PublicService {
    @EJB
    private DataMgr dm;
    private LoanMgr lm;
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Web Service Operation")

    @WebMethod(operationName = "loanMedium")
    public Loan loanMedium(@WebParam(name = "id") int id, @WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName) {
        return lm.loanMedium(id, firstName, lastName);
    }

    @WebMethod(operationName = "returnMedium")
    //@Oneway
    public Exemplar returnMedium(@WebParam(name = "id") int id) {
        return lm.returnMedium(id);
    }

    @WebMethod(operationName = "searchMedium")
    public Medium searchMedium(@WebParam(name = "title") String title) {
        return lm.searchMedium(title);
    }

    @WebMethod(operationName = "reserveMedium")
    @Oneway
    public void reserveMedium(@WebParam(name = "id") int id) {
        lm.reserveMedium(id);
    }

    @WebMethod(operationName = "cancelReservation")
    @Oneway
    public void cancelReservation(@WebParam(name = "id") int id) {
        lm.cancelReservation(id);
    }

    @WebMethod(operationName = "askOwnState")
    public Loan askOwnState(@WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName) {
        return lm.askOwnState(firstName, lastName);
    }
    
    @WebMethod(operationName = "listMedia")
    public List<Medium> listMedia() {
        //List<Medium> strList = new ArrayList<Medium>();
        List<Medium> media = dm.getAllMedia();
        return media;
      
    }
    
    @WebMethod(operationName = "searchClient")
    public Client searchClient(@WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName) {
            return lm.searchClient(firstName, lastName);
    }
    
}
